package com.wuwei.business.controller;

import com.wuwei.business.VO.BackVo;
import com.wuwei.business.VO.RentVo;
import com.wuwei.business.domain.BusCheck;
import com.wuwei.business.domain.BusRent;
import com.wuwei.business.service.BusCheckService;
import com.wuwei.business.service.BusRentService;
import com.wuwei.common.core.controller.BaseController;
import com.wuwei.common.core.domain.AjaxResult;
import com.wuwei.common.core.domain.model.LoginUser;
import com.wuwei.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 内容: SSM
 * 作者: weishao
 */
@RestController
@RequestMapping("business/backCar")
public class BackCarConntroller extends BaseController {
    @Autowired
    private BusRentService busRentService;
    @Autowired
    private BusCheckService busCheckService;

    /**
     * 通过账单号查询还车数据
     * @param rentSn 账单号
     * @return backVo 把数据存在里面
     */
    @GetMapping("checkRentSn")
    public AjaxResult checkRentSn(String rentSn){
        BackVo backVo=busRentService.checkRentSn(rentSn);
        return AjaxResult.success(backVo);
    }

    @PostMapping("doBackCar")
    public AjaxResult doBackCar(@RequestBody BusCheck busCheck){
        LoginUser loginUser = getLoginUser();
       Boolean flag =busCheckService.doBackCar(loginUser,busCheck);
       return AjaxResult.success(flag ? "还车成功":"还车失败");
    }

}
